package com.freemalll.merchant.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.freemalll.common.core.annotation.ResultInterceptor;
import com.freemalll.merchant.domain.dto.coopManagement.AssetLogPageDto;
import com.freemalll.merchant.domain.dto.coopManagement.AssetManageDto;
import com.freemalll.merchant.domain.dto.coopManagement.AssetManagePageDto;
import com.freemalll.merchant.domain.dto.coopManagement.AssetRateEditDto;
import com.freemalll.merchant.domain.vo.coopManagement.AssetRateLogPageVo;
import com.freemalll.merchant.domain.vo.coopManagement.AssetRatePageVo;
import com.freemalll.merchant.service.coopManagement.MerAssetLogService;
import com.freemalll.merchant.service.coopManagement.MerAssetRateManageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author songshixiong
 * @ClassName AssetRateManagementController
 * @description:
 * @date 2025年05月16日
 * @version: 1.0
 */
@Tag(name = "合作管理：费率管理")
@RestController
@RequestMapping("/cooperative/asset-rate")
@ResultInterceptor
@AllArgsConstructor
public class AssetRateManagementController {

    private final MerAssetRateManageService merAssetRateManageService;
    private final MerAssetLogService merAssetLogService;

    @PostMapping("/page")
    @Operation(summary = "分页")
    public Page<AssetRatePageVo> pageSearch(@RequestBody AssetManagePageDto dto) {
        return merAssetRateManageService.pageSearch(dto);
    }

    @PostMapping("/edit")
    @Operation(summary = "编辑")
    public void edit(@RequestBody List<AssetRateEditDto> dto) {
        merAssetRateManageService.edit(dto);
    }

    @PostMapping("/operationLogPage")
    @Operation(summary = "操作日志分页")
    public Page<AssetRateLogPageVo> operationLogPage(@RequestBody AssetLogPageDto dto) {
        return merAssetLogService.operationLogPage(dto);
    }

    @DeleteMapping("/remove/{id}")
    @Operation(summary = "根据sourceId或templateCode删除费率")
    public void removeRate(@PathVariable("id") String id) {
        merAssetRateManageService.removeRate(id);
    }


    @PostMapping("/getRateList")
    @Operation(summary = "根据资方id和息费模式获取数据")
    public List<AssetRatePageVo> getRateList(@RequestBody @Valid AssetManageDto dto) {
        return merAssetRateManageService.getRateList(dto);
    }


}
